<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        new Promise((resolve,reject)=>{
            setTimeout(()=>{
                var result = '12321'
                if(result){
                    resolve(result)
                }else{
                    reject('你请求的数据有误')
                }
            },3000)
        }).then((data)=>{
            console.log(data)
        }).catch((err)=>{
            console.log(err)
        }).finally(()=>{
            console.log('finally')
        })

        var p1 = new Promise((resolve,reject)=>{
            resolve('p1 成功了')
        })
        var p2 = new Promise((resolve,reject)=>{
            reject('p2 报错了')
        })
        var p3 = new Promise((resolve,reject)=>{
            resolve('p3 成功了')
        })

        Promise.all([p1,p2,p3]).then((result)=>{
            console.log(result)
        }).catch((err)=>{
            console.log(err)
        })

        var p4 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                resolve('p4 成功了')
            })
        })
        var p5 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                reject('p5 报错了')
            })
        })
        var p6 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                resolve('p6 成功了')
            })
        })

        Promise.race([p4,p5,p6]).then((result)=>{
            console.log(result)
        }).catch((err)=>{
            console.log(err)
        })
    </script>
</body>
</html>